using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Sdk.Sfc;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.SqlManagerUI.Scripting;
using Microsoft.SqlServer.Management.SqlMgmt;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Windows.Forms;

namespace Microsoft.SqlServer.Management.SqlManagerUI
{
using Server = Microsoft.SqlServer.Management.Smo.Server;
	internal class GenWizGeneralData
	{
		public enum ScriptFileType
		{
			ANSI,
			UNICODE,
			NONE
		}

		public enum ScriptDestination
		{
			ToSingleFile,
			ToClipboard,
			ToEditor,
			ToFilePerObject,
			ToProvider
		}

		private CDataContainer dataContainer;

		private string saveFileName;

		private ProviderEntity _provider;

		private DatabaseEntity _database;

		private GenWizGeneralData.ScriptDestination saveScriptDestination;

		private GenWizGeneralData.ScriptFileType saveFileType;

		private bool scriptAllObjects;

		private DataTable databaseTable;

		private bool fileInfoValidated;

		private bool overwriteExistingFile;

		private ScriptingDriver _scriptingDriver;

		private SqlConnectionInfo _connectionInfo;

		private bool _connStringDb;

		private Database _databaseObject;

		public ScriptingDriver ScriptingDriver
		{
			get
			{
				return this._scriptingDriver;
			}
			set
			{
				this._scriptingDriver = value;
			}
		}

		public bool ConnectionStringDB
		{
			get
			{
				return this._connStringDb;
			}
			set
			{
				this._connStringDb = value;
			}
		}

		public string DatabaseName
		{
			get
			{
				return this._scriptingDriver.DatabaseName;
			}
			set
			{
				this._scriptingDriver.DatabaseName = value;
				this.InitDatabaseObject();
				this.SaveFileName = this.GenerateDefaultFileName();
			}
		}

		public SqlConnectionInfo ConnectionInfo
		{
			get
			{
				return this._connectionInfo;
			}
			set
			{
				this._connectionInfo = value;
				this.ClearItems();
			}
		}

		public string ServerName
		{
			get
			{
				return this._scriptingDriver.ServerConnection.ServerInstance;
			}
		}

		public Server ServerObject
		{
			get
			{
				return this._scriptingDriver.ServerObject;
			}
		}

		public int SqlServerVersion
		{
			get
			{
				return this._scriptingDriver.ServerConnection.ServerVersion.Major;
			}
		}

		public GenWizGeneralData.ScriptDestination SaveScriptDestination
		{
			get
			{
				return this.saveScriptDestination;
			}
			set
			{
				this.fileInfoValidated = false;
				this.saveScriptDestination = value;
			}
		}

		public GenWizGeneralData.ScriptFileType SaveFileType
		{
			get
			{
				return this.saveFileType;
			}
			set
			{
				this.saveFileType = value;
			}
		}

		public string SaveFileName
		{
			get
			{
				if (string.IsNullOrEmpty(this.saveFileName))
				{
					this.SaveFileName = this.GenerateDefaultFileName();
				}
				return this.saveFileName;
			}
			set
			{
				this.fileInfoValidated = false;
				this.saveFileName = value;
			}
		}

		public ProviderEntity Provider
		{
			get
			{
				return this._provider;
			}
			set
			{
				this._provider = value;
			}
		}

		public DatabaseEntity Database
		{
			get
			{
				return this._database;
			}
			set
			{
				this._database = value;
			}
		}

		public bool OverwriteExistingFile
		{
			get
			{
				return this.overwriteExistingFile;
			}
			set
			{
				this.overwriteExistingFile = value;
			}
		}

		public bool FileInfoValidated
		{
			get
			{
				return this.fileInfoValidated;
			}
			set
			{
				this.fileInfoValidated = value;
			}
		}

		public bool ScriptAllObjects
		{
			get
			{
				return this.scriptAllObjects;
			}
			set
			{
				this.scriptAllObjects = value;
			}
		}

		public CDataContainer DataContainer
		{
			get
			{
				return this.dataContainer;
			}
		}

		private bool IsServerVersion2005
		{
			get
			{
				return this.SqlServerVersion == 9;
			}
		}

		public GenWizGeneralData(CDataContainer data)
		{
			this.dataContainer = data;
		}

		private void InitDatabaseObject()
		{
			Server serverObject = this._scriptingDriver.ServerObject;
			serverObject.SetDefaultInitFields(typeof(Table), new string[]
			{
				"Name",
				"IsSystemObject",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(UserDefinedFunction), new string[]
			{
				"Name",
				"IsSystemObject",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(UserDefinedDataType), new string[]
			{
				"Name",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(StoredProcedure), new string[]
			{
				"Name",
				"IsSystemObject",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(Default), new string[]
			{
				"Name",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(Microsoft.SqlServer.Management.Smo.View), new string[]
			{
				"Name",
				"IsSystemObject",
				"Urn",
				"Schema"
			});
			serverObject.SetDefaultInitFields(typeof(ApplicationRole), new string[]
			{
				"Name",
				"Urn"
			});
			serverObject.SetDefaultInitFields(typeof(User), new string[]
			{
				"Name",
				"IsSystemObject",
				"Urn",
				"LoginType"
			});
			serverObject.SetDefaultInitFields(typeof(DatabaseRole), new string[]
			{
				"Name",
				"IsFixedRole",
				"Urn"
			});
			serverObject.SetDefaultInitFields(typeof(FullTextCatalog), new string[]
			{
				"Name",
				"Urn"
			});
			serverObject.SetDefaultInitFields(typeof(Microsoft.SqlServer.Management.Smo.Rule), new string[]
			{
				"Name",
				"Urn",
				"Schema"
			});
			if (this.IsServerVersion2005)
			{
				serverObject.SetDefaultInitFields(typeof(Schema), new string[]
				{
					"Name",
					"ID",
					"Urn"
				});
				serverObject.SetDefaultInitFields(typeof(DatabaseDdlTrigger), new string[]
				{
					"IsSystemObject",
					"Name",
					"Urn"
				});
				serverObject.SetDefaultInitFields(typeof(Synonym), new string[]
				{
					"Name",
					"Urn",
					"Schema"
				});
				serverObject.SetDefaultInitFields(typeof(UserDefinedAggregate), new string[]
				{
					"Name",
					"Urn",
					"Schema"
				});
				serverObject.SetDefaultInitFields(typeof(XmlSchemaCollection), new string[]
				{
					"Name",
					"Urn",
					"Schema"
				});
				serverObject.SetDefaultInitFields(typeof(SqlAssembly), new string[]
				{
					"Name",
					"Urn"
				});
				serverObject.SetDefaultInitFields(typeof(UserDefinedType), new string[]
				{
					"Name",
					"Urn",
					"Schema"
				});
			}
			this._databaseObject = serverObject.Databases[this._scriptingDriver.DatabaseName];
		}

		public DataTable GetDatabases()
		{
			if (this.databaseTable == null)
			{
				Request request = new Request();
				request.Urn = "Server/Database[@IsAccessible = true()]";
				request.Fields = new string[]
				{
					"Name",
					"CompatibilityLevel"
				};
				request.OrderByList = new OrderBy[]
				{
					new OrderBy("Name", OrderBy.Direction.Asc)
				};
				this.databaseTable = Enumerator.GetData(this.ConnectionInfo, request);
				if (this.SqlServerVersion < 10)
				{
					for (int i = 0; i < this.databaseTable.Rows.Count; i++)
					{
						if (int.Parse(this.databaseTable.Rows[i]["CompatibilityLevel"].ToString()) <= 70)
						{
							this.databaseTable.Rows.RemoveAt(i);
							i--;
						}
					}
				}
			}
			return this.databaseTable;
		}

		public void ClearItems()
		{
			this.databaseTable = null;
		}

		public void AddGeneralDescription(TreeNode topNode)
		{
			TreeNode treeNode = new TreeNode();
			treeNode.Text = GenScriptWizSR.ReviewSource;
			TreeNode treeNode2 = new TreeNode();
			treeNode2.Text = GenScriptWizSR.OptionsServerDesc;
			treeNode2.Nodes.Add(this.ServerName);
			treeNode.Nodes.Add(treeNode2);
			treeNode2 = new TreeNode();
			treeNode2.Text = GenScriptWizSR.OptionsDatabaseDesc;
			treeNode2.Nodes.Add(this.DatabaseName);
			treeNode.Nodes.Add(treeNode2);
			if (!this.ConnectionInfo.UseIntegratedSecurity)
			{
				treeNode2 = new TreeNode();
				treeNode2.Text = GenScriptWizSR.ReviewUsername;
				treeNode2.Nodes.Add(this.ConnectionInfo.UserName);
				treeNode.Nodes.Add(treeNode2);
			}
			topNode.Nodes.Add(treeNode);
		}

		public void AddOutputDescription(TreeNode topNode)
		{
			TreeNode treeNode = new TreeNode(GenScriptWizSR.ReviewTarget);
			TreeNode treeNode2 = new TreeNode();
			if (this.saveScriptDestination == GenWizGeneralData.ScriptDestination.ToSingleFile)
			{
				if (this.SaveFileType != GenWizGeneralData.ScriptFileType.ANSI)
				{
					GenWizGeneralData.ScriptFileType arg_2D_0 = this.SaveFileType;
				}
				TreeNode treeNode3 = new TreeNode();
				treeNode3.Text = this.SaveFileName;
				treeNode2.Text = GenScriptWizSR.ReviewSingleFile;
				treeNode2.Nodes.Add(treeNode3);
			}
			else if (this.saveScriptDestination == GenWizGeneralData.ScriptDestination.ToClipboard)
			{
				treeNode2.Text = GenScriptWizSR.ScriptToClipboard;
			}
			else if (this.saveScriptDestination == GenWizGeneralData.ScriptDestination.ToEditor)
			{
				treeNode2.Text = GenScriptWizSR.ScriptToEditor;
			}
			else if (this.saveScriptDestination == GenWizGeneralData.ScriptDestination.ToProvider)
			{
				TreeNode treeNode4 = new TreeNode();
				treeNode4.Text = GenScriptWizSR.ReviewHosterName;
				treeNode4.Nodes.Add(this.Provider.Name);
				treeNode2.Nodes.Add(treeNode4);
				treeNode4 = new TreeNode();
				treeNode4.Text = GenScriptWizSR.ReviewHosterDatabase;
				treeNode4.Nodes.Add(this.Database.DatabaseName);
				treeNode2.Nodes.Add(treeNode4);
				treeNode2.Text = GenScriptWizSR.ReviewHoster;
			}
			treeNode.Nodes.Add(treeNode2);
			topNode.Nodes.Add(treeNode);
		}

		public List<ObjectInfo> GetObjectsList(GenScriptWizForm.ScriptWizardPage pageId, bool onlyCheckCount, out bool exists)
		{
			exists = false;
			List<ObjectInfo> list = null;
			if (!onlyCheckCount)
			{
				list = new List<ObjectInfo>();
			}
			if (this._databaseObject != null)
			{
				switch (pageId)
				{
				case GenScriptWizForm.ScriptWizardPage.ApplicationRoles:
					goto IL_30A;
				case GenScriptWizForm.ScriptWizardPage.Assemblies:
					goto IL_741;
				case GenScriptWizForm.ScriptWizardPage.DatabaseTriggers:
					goto IL_567;
				case GenScriptWizForm.ScriptWizardPage.DatabaseRoles:
					goto IL_3E5;
				case GenScriptWizForm.ScriptWizardPage.Defaults:
					goto IL_29F;
				case GenScriptWizForm.ScriptWizardPage.Rules:
					goto IL_823;
				case GenScriptWizForm.ScriptWizardPage.Schemas:
					goto IL_4D2;
				case GenScriptWizForm.ScriptWizardPage.StoredProcedures:
					goto IL_1B7;
				case GenScriptWizForm.ScriptWizardPage.Synonyms:
					goto IL_5DF;
				case GenScriptWizForm.ScriptWizardPage.Tables:
				{
					IEnumerator enumerator = this._databaseObject.Tables.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							Table table = (Table)enumerator.Current;
							if (!table.IsSystemObject)
							{
								exists = true;
								if (onlyCheckCount)
								{
									break;
								}
								list.Add(new ObjectInfo(table.Name, table.Urn, table.Schema));
							}
						}
						return list;
					}
					finally
					{
						IDisposable disposable = enumerator as IDisposable;
						if (disposable != null)
						{
							disposable.Dispose();
						}
					}
					break;
				}
				case GenScriptWizForm.ScriptWizardPage.UserDefinedDataTypes:
					goto IL_150;
				case GenScriptWizForm.ScriptWizardPage.UserDefinedFunctions:
					break;
				case GenScriptWizForm.ScriptWizardPage.UserDefinedAggregate:
					goto IL_655;
				case GenScriptWizForm.ScriptWizardPage.UserDefinedType:
					goto IL_7B0;
				case GenScriptWizForm.ScriptWizardPage.Users:
					goto IL_36E;
				case GenScriptWizForm.ScriptWizardPage.Views:
					goto IL_22B;
				case GenScriptWizForm.ScriptWizardPage.XmlSchemaCollections:
					goto IL_6CB;
				case GenScriptWizForm.ScriptWizardPage.FullTextCatalog:
                    //goto IL_466;
                    throw new Exception("MY: not IL_466 label");
				default:
					return list;
				}
				IEnumerator enumerator2 = this._databaseObject.UserDefinedFunctions.GetEnumerator();
				try
				{
					while (enumerator2.MoveNext())
					{
						UserDefinedFunction userDefinedFunction = (UserDefinedFunction)enumerator2.Current;
						if (!userDefinedFunction.IsSystemObject)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(userDefinedFunction.Name, userDefinedFunction.Urn, userDefinedFunction.Schema));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable2 = enumerator2 as IDisposable;
					if (disposable2 != null)
					{
						disposable2.Dispose();
					}
				}
				IL_150:
				IEnumerator enumerator3 = this._databaseObject.UserDefinedDataTypes.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						UserDefinedDataType userDefinedDataType = (UserDefinedDataType)enumerator3.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(userDefinedDataType.Name, userDefinedDataType.Urn, userDefinedDataType.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable3 = enumerator3 as IDisposable;
					if (disposable3 != null)
					{
						disposable3.Dispose();
					}
				}
				IL_1B7:
				IEnumerator enumerator4 = this._databaseObject.StoredProcedures.GetEnumerator();
				try
				{
					while (enumerator4.MoveNext())
					{
						StoredProcedure storedProcedure = (StoredProcedure)enumerator4.Current;
						if (!storedProcedure.IsSystemObject)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(storedProcedure.Name, storedProcedure.Urn, storedProcedure.Schema));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable4 = enumerator4 as IDisposable;
					if (disposable4 != null)
					{
						disposable4.Dispose();
					}
				}
				IL_22B:
				IEnumerator enumerator5 = this._databaseObject.Views.GetEnumerator();
				try
				{
					while (enumerator5.MoveNext())
					{
						Microsoft.SqlServer.Management.Smo.View view = (Microsoft.SqlServer.Management.Smo.View)enumerator5.Current;
						if (!view.IsSystemObject)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(view.Name, view.Urn, view.Schema));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable5 = enumerator5 as IDisposable;
					if (disposable5 != null)
					{
						disposable5.Dispose();
					}
				}
				IL_29F:
				IEnumerator enumerator6 = this._databaseObject.Defaults.GetEnumerator();
				try
				{
					while (enumerator6.MoveNext())
					{
						Default @default = (Default)enumerator6.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(@default.Name, @default.Urn, @default.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable6 = enumerator6 as IDisposable;
					if (disposable6 != null)
					{
						disposable6.Dispose();
					}
				}
				IL_30A:
				IEnumerator enumerator7 = this._databaseObject.ApplicationRoles.GetEnumerator();
				try
				{
					while (enumerator7.MoveNext())
					{
						ApplicationRole applicationRole = (ApplicationRole)enumerator7.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(applicationRole.Name, applicationRole.Urn));
					}
					return list;
				}
				finally
				{
					IDisposable disposable7 = enumerator7 as IDisposable;
					if (disposable7 != null)
					{
						disposable7.Dispose();
					}
				}
				IL_36E:
				IEnumerator enumerator8 = this._databaseObject.Users.GetEnumerator();
				try
				{
					while (enumerator8.MoveNext())
					{
						User user = (User)enumerator8.Current;
						if (!user.IsSystemObject && user.LoginType == LoginType.SqlLogin)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(user.Name, user.Urn));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable8 = enumerator8 as IDisposable;
					if (disposable8 != null)
					{
						disposable8.Dispose();
					}
				}
				IL_3E5:
				IEnumerator enumerator9 = this._databaseObject.Roles.GetEnumerator();
				try
				{
					while (enumerator9.MoveNext())
					{
						DatabaseRole databaseRole = (DatabaseRole)enumerator9.Current;
						if (!databaseRole.IsFixedRole && !databaseRole.Name.Equals("public", StringComparison.OrdinalIgnoreCase))
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(databaseRole.Name, databaseRole.Urn));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable9 = enumerator9 as IDisposable;
					if (disposable9 != null)
					{
						disposable9.Dispose();
					}
				}
				try
				{
					IL_466:
					foreach (FullTextCatalog fullTextCatalog in this._databaseObject.FullTextCatalogs)
					{
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(fullTextCatalog.Name, fullTextCatalog.Urn));
					}
					return list;
				}
				catch (UnsupportedFeatureException)
				{
					return list;
				}
				IL_4D2:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator11 = this._databaseObject.Schemas.GetEnumerator();
				try
				{
					while (enumerator11.MoveNext())
					{
						Schema schema = (Schema)enumerator11.Current;
						if ((schema.ID > 4 && schema.ID < 16384) || schema.ID > 16400)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(schema.Name, schema.Urn));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable11 = enumerator11 as IDisposable;
					if (disposable11 != null)
					{
						disposable11.Dispose();
					}
				}
				IL_567:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator12 = this._databaseObject.Triggers.GetEnumerator();
				try
				{
					while (enumerator12.MoveNext())
					{
						DatabaseDdlTrigger databaseDdlTrigger = (DatabaseDdlTrigger)enumerator12.Current;
						if (!databaseDdlTrigger.IsSystemObject)
						{
							exists = true;
							if (onlyCheckCount)
							{
								break;
							}
							list.Add(new ObjectInfo(databaseDdlTrigger.Name, databaseDdlTrigger.Urn));
						}
					}
					return list;
				}
				finally
				{
					IDisposable disposable12 = enumerator12 as IDisposable;
					if (disposable12 != null)
					{
						disposable12.Dispose();
					}
				}
				IL_5DF:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator13 = this._databaseObject.Synonyms.GetEnumerator();
				try
				{
					while (enumerator13.MoveNext())
					{
						Synonym synonym = (Synonym)enumerator13.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(synonym.Name, synonym.Urn, synonym.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable13 = enumerator13 as IDisposable;
					if (disposable13 != null)
					{
						disposable13.Dispose();
					}
				}
				IL_655:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator14 = this._databaseObject.UserDefinedAggregates.GetEnumerator();
				try
				{
					while (enumerator14.MoveNext())
					{
						UserDefinedAggregate userDefinedAggregate = (UserDefinedAggregate)enumerator14.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(userDefinedAggregate.Name, userDefinedAggregate.Urn, userDefinedAggregate.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable14 = enumerator14 as IDisposable;
					if (disposable14 != null)
					{
						disposable14.Dispose();
					}
				}
				IL_6CB:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator15 = this._databaseObject.XmlSchemaCollections.GetEnumerator();
				try
				{
					while (enumerator15.MoveNext())
					{
						XmlSchemaCollection xmlSchemaCollection = (XmlSchemaCollection)enumerator15.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(xmlSchemaCollection.Name, xmlSchemaCollection.Urn, xmlSchemaCollection.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable15 = enumerator15 as IDisposable;
					if (disposable15 != null)
					{
						disposable15.Dispose();
					}
				}
				IL_741:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator16 = this._databaseObject.Assemblies.GetEnumerator();
				try
				{
					while (enumerator16.MoveNext())
					{
						SqlAssembly sqlAssembly = (SqlAssembly)enumerator16.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(sqlAssembly.Name, sqlAssembly.Urn));
					}
					return list;
				}
				finally
				{
					IDisposable disposable16 = enumerator16 as IDisposable;
					if (disposable16 != null)
					{
						disposable16.Dispose();
					}
				}
				IL_7B0:
				if (!this.IsServerVersion2005)
				{
					return list;
				}
				IEnumerator enumerator17 = this._databaseObject.UserDefinedTypes.GetEnumerator();
				try
				{
					while (enumerator17.MoveNext())
					{
						UserDefinedType userDefinedType = (UserDefinedType)enumerator17.Current;
						exists = true;
						if (onlyCheckCount)
						{
							break;
						}
						list.Add(new ObjectInfo(userDefinedType.Name, userDefinedType.Urn, userDefinedType.Schema));
					}
					return list;
				}
				finally
				{
					IDisposable disposable17 = enumerator17 as IDisposable;
					if (disposable17 != null)
					{
						disposable17.Dispose();
					}
				}
				IL_823:
				foreach (Microsoft.SqlServer.Management.Smo.Rule rule in this._databaseObject.Rules)
				{
					exists = true;
					if (onlyCheckCount)
					{
						break;
					}
					list.Add(new ObjectInfo(rule.Name, rule.Urn, rule.Schema));
				}
			}
			return list;
		}

		private string GenerateDefaultFileName()
		{
			string fileName = Path.GetFileName(this.DatabaseName);
			return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), (string.IsNullOrEmpty(fileName) ? "script" : fileName) + ".sql");
		}
	}
}
